package io.renren.admin;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.entity.TPurviewCustinfoEntity;
import io.renren.service.TPurviewCustinfoService;
import io.renren.utils.PageUtils;
import io.renren.utils.Query;
import io.renren.utils.R;


/**
 * 客户信息
 * 
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-02-06 17:41:04
 */
@RestController
@RequestMapping("tpurviewcustinfo")
public class TPurviewCustinfoController {
	@Autowired
	private TPurviewCustinfoService tPurviewCustinfoService;
		
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("tpurviewcustinfo:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<TPurviewCustinfoEntity> tPurviewCustinfoList = tPurviewCustinfoService.queryList(query);
		int total = tPurviewCustinfoService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(tPurviewCustinfoList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	@RequestMapping("/custinfolist")
	@RequiresPermissions("tpurviewcustinfo:custinfolist")
	public List<TPurviewCustinfoEntity> custinfolist(@RequestParam Map<String, Object> params){
		//查询列表数据

		List<TPurviewCustinfoEntity> tPurviewCustinfoList = tPurviewCustinfoService.CustinfoList();
	
		return tPurviewCustinfoList;
	}
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("tpurviewcustinfo:info")
	public R info(@PathVariable("id") String id){
		TPurviewCustinfoEntity tPurviewCustinfo = tPurviewCustinfoService.queryObject(id);
		
		return R.ok().put("tPurviewCustinfo", tPurviewCustinfo);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("tpurviewcustinfo:save")
	public R save(@RequestBody TPurviewCustinfoEntity tPurviewCustinfo){
		
		tPurviewCustinfoService.save(tPurviewCustinfo);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("tpurviewcustinfo:update")
	public R update(@RequestBody TPurviewCustinfoEntity tPurviewCustinfo){
		tPurviewCustinfoService.update(tPurviewCustinfo);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("tpurviewcustinfo:delete")
	public R delete(@RequestBody String[] ids){
		tPurviewCustinfoService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
